package com.wxg.domain.table;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.junit.Test;

public class NestedListTest {

	@Test
	public void test001(){
		List<List<Object>> dblist = new ArrayList<List<Object>>();
		dblist.add(createSubList("xiaohong", "nihao", 23));
		dblist.add(createSubList("Jack", "Hello", 32));
		
		System.out.println( dblist.get(0).get(0) );
		
		int outsize = dblist.size();
		Object[][] objArr = new Object[outsize][3];
		for(int i=0; i<outsize; i++){
			List<Object> sublist = dblist.get(i);
			int insize = sublist.size();
			for(int j=0; j<insize; j++){
				objArr[i][j] = sublist.get(j);
			}
		}
		System.out.println( String.format("objArr.length is %d", objArr.length) );
		System.out.println( String.format("Arrays.toString(objArr) = %s", Arrays.toString(objArr)) );
		System.out.println("================");
		for(int i=0; i<objArr.length; i++){
			System.out.println( String.format("Arrays.toString(objArr[%d]) = %s", i,Arrays.toString(objArr[i])) );
		}
	}
	
	private List<Object> createSubList(String name, String msg, int age){
		List<Object> sublist = new ArrayList<Object>(3);
		sublist.add(name);
		sublist.add(msg);
		sublist.add(age);
		return sublist;
	}
}
